package com.allwees.core.common.context;

public abstract class AbstractHandler<T> {

    protected AbstractHandler nextHandler;

    public abstract T handler(T request);

    protected T doNext(T request) {
        if (nextHandler != null) {
            return (T) nextHandler.handler(request);
        }
        return request;
    }

    public AbstractHandler setNextHandler(AbstractHandler nextHandler) {
        this.nextHandler = nextHandler;
        return this.nextHandler;
    }
}
